package com.kaifamiao.listener;

import org.tinylog.Logger;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * 监听与ServletContext生命周期相关的事件
 */
public class ApplicationListener implements ServletContextListener {

    // 当 Servlet容器 成功 "启动" 当前 "web application" 时 调用此方法
    @Override
    public void contextInitialized(ServletContextEvent event) {
        ServletContext app = event.getServletContext();
        Logger.trace("成功初始化{}应用", app.getContextPath());
    }

    // 当 Servlet容器 成功 "停止" 当前 "web application" 时 调用此方法
    @Override
    public void contextDestroyed(ServletContextEvent event) {
        ServletContext app = event.getServletContext();
        Logger.trace("成功销毁{}应用", app.getContextPath());
    }

}
